#ifndef KEYBOARD_H
#define KEYBOARD_H

#include <QWidget>

namespace Ui {
class Keyboard;
}
class QGridLayout; class QPushButton;
class Keyboard : public QWidget
{

Q_OBJECT
public:
    explicit Keyboard(QWidget *parent = nullptr);
    ~Keyboard();

Q_SIGNALS:
    void Commit(const QString&);

public Q_SLOTS:
    uint DoInput(uint keysym);
    void SetCursorRect(int x, int y, int w, int h);
    void ShowKeyboard();
    void HideKeyboard();

protected:
    virtual void resizeEvent(QResizeEvent *event) override;
private Q_SLOTS:
    void onTextBtnClicked();
    void onHideBtnClicked();
    void onReturnBtnClicked(); //返回按钮
    void onEnterBtnClicked(); //回车按钮
    void onDeleteBtnClicked();
    void onSymbolBtnClicked();
    void onLanguageBtnClicked();
    void onAndBtnClicked();
    void onCapsBtnClicked();
    void onSpaceBtnClicked();
    void onDesktopResized();

private:
    void bindSignal();
    uint handleKeyLeft();
    uint handleKeyRight();
    uint handleKeyUp();
    uint handleKeyDown();
    uint handleKeyReturn(); //Enter键
    void checkSender(QPushButton *btn);


private:
    Ui::Keyboard *ui;
    typedef decltype(&Keyboard::onTextBtnClicked) KMFVVP;
    std::map<QString, KMFVVP> kbdBtnSlots;
};

#endif // KEYBOARD_H
